//index.js
//获取应用实例
const app = getApp()
var api = require('../../../app/app.js')
Page({
  data: {
    IMG_URL: 'https://www.sdhjfu.com/smallhouse/public/admin/',
    dayu: 'https://www.sdhjfu.com/smallhouse/public/tianxing/images/dayu.jpg',
    shareIcon: 'https://www.sdhjfu.com/smallhouse/public/tianxing/images/shareIcon.jpg',
    telIcon: 'https://www.sdhjfu.com/smallhouse/public/tianxing/images/telIcon.jpg',
    vertical: true,
    autoplay: true,
    interval: 3500,
    duration: 800,
    userPhone: {}
  },
  onLoad: function () { // 获取首页数据
    wx.showLoading({ // 加载数据前的loading
      title: '加载中'
    })
    var that = this
    wx.request({
      url: api.Index,
      method: 'GET', //请求方式
      data: {}, //请求参数格式为json
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        wx.hideLoading() // 数据调出后关闭loading
       // console.log(res.data)
        that.setData({
          houseInfo: res.data
        })
        that.data.userPhone = res.data.houre[0].house_iphone
        wx.setStorageSync('userPhone', that.data.userPhone) // 本地异步存储
      }
    })
  },
  addressClick: function () {
    var long = 117.751491
    var lati = 36.843223
    wx.openLocation({
      latitude: lati,
      longitude: long,
      name: '天兴·理想之城',
      address: '邹平市鹤伴五路与醴泉五路交汇处南200米路东项目现场营销中心'
    })
  },
  addressClick_1: function () {
    var long = 117.737206
    var lati = 36.864433
    wx.openLocation({
      latitude: lati,
      longitude: long,
      name: '天兴·理想之城',
      address: '邹平市山南圣豪超市停车场东临鹤伴一路营销中心'
    })
  },
  // 跳转项目详情页
  companyClick: function() {
    wx.navigateTo({
      url: '../components/objectDetails/objectDetails',
    })
  },
  // 全景介绍预览图片
  panorama_left: function () {
    var panoramaLeftImgListCurrent = this.data.IMG_URL + this.data.houseInfo.panorama[0].pictureimg
    var panoramaLeftImgList = this.data.houseInfo.panorama[0].twoimg
    var result = []
    for (let i in panoramaLeftImgList) {
      result[i] = this.data.IMG_URL + panoramaLeftImgList[i]
    }
    wx.previewImage({
      current: panoramaLeftImgListCurrent, // 当前显示图片的http链接
      urls: result // 需要预览的图片http链接列表
    })
  },
  panorama_right_top: function () {
    var panoramaLeftImgListCurrent = this.data.IMG_URL + this.data.houseInfo.panorama[1].pictureimg
    var panoramaLeftImgList = this.data.houseInfo.panorama[1].twoimg
    var result = []
    for (let i in panoramaLeftImgList) {
      result[i] = this.data.IMG_URL + panoramaLeftImgList[i]
    }
    wx.previewImage({
      current: panoramaLeftImgListCurrent, // 当前显示图片的http链接
      urls: result // 需要预览的图片http链接列表
    })
  },
  panorama_right_bottom: function () {
    var panoramaLeftImgListCurrent = this.data.IMG_URL + this.data.houseInfo.panorama[2].pictureimg
    var panoramaLeftImgList = this.data.houseInfo.panorama[2].twoimg
    var result = []
    for (let i in panoramaLeftImgList) {
      result[i] = this.data.IMG_URL + panoramaLeftImgList[i]
    }
    wx.previewImage({
      current: panoramaLeftImgListCurrent, // 当前显示图片的http链接
      urls: result // 需要预览的图片http链接列表
    })
  },
  // 跳转楼盘图册
  atlasClick: function() {
    wx.navigateTo({
      url: '../components/atlas/atlas',
    })
  },
  // 跳转楼盘新闻
  newsClick: function() {
    wx.navigateTo({
      url: '../components/news/news',
    })
  },
  // 拨打电话
  telClick: function() {
    wx.makePhoneCall({
      phoneNumber: this.data.houseInfo.houre[0].house_iphone,
    })
  },
  // 拨打电话
  telClick1: function () {
    wx.makePhoneCall({
      phoneNumber: this.data.houseInfo.houre[0].house_iphoneone,
    })
  }
})